package org.example;
import java.io.*;
import java.util.*;
// 按两次 Shift 打开“随处搜索”对话框并输入 `show whitespaces`，
// 然后按 Enter 键。现在，您可以在代码中看到空格字符。
public class Main {
    public static void main(String[] args) {
        File file = new File("a. txt");
        Scanner sc = null;
        double sum = 0;
        int count = 0;
        try {
            sc = new Scanner(file);
            sc.useDelimiter("[^0123456789.]+");
            while (sc.hasNext()) {
                try {
                    double price = sc.nextDouble();
                    count++;
                    sum = sum + price;
                    System.out.println(price);
                } catch (InputMismatchException exp) {
                    String t = sc.next();
                }
            }
            System.out.println("平均价格:" + sum / count);
        }
        catch (Exception exp){
            System.out.println(exp);
        }
    }
}